set proc to sospro
set proc to boxproc
set function 10 to space(2)
dr='n:'
f1='PROGRAM'
set exclu off
use &dr&f1
go bottom
set colo to bg+/b,w+/n
@ 4,1 CLEAR TO 23,78
DO BOXT WITH 4,3,"INPUT AEA PROGRAM",'BG+','GR',.F.,.T.
SET COLO TO BG+/B,W+/N
set inte off
@ 10, 5 say 'C O D E         :    '
@ 11, 5 say 'PROGRAM NAME    :                  '

set color to w
del_rec = 'N'
option = 1
do while option <9
   set deli off
   record_no = recno()
   kode     = PROGRAM_CD
   name     = PROGRAM_NM
   SET COLO TO BG+/B,W+/N
   @ 10,23 say kode
   @ 11,23 say name
   SET COLO TO BG+/B,W+/N
   @ 12,2 CLEAR TO 23,78
   LY1=SAVESCREEN(0,0,24,79)
   SELE 1
   do mn_formm
   do case
      case option = 1
            COUNT TO CNT
            DECLARE FILD[CNT]
            DECLARE KODI[CNT]
            DECLARE NADI[CNT]
            CR=0
            GO TOP
            DO WHILE .NOT. EOF()
               CR=CR+1
               FILD[CR]=PROGRAM_CD+' '+PROGRAM_NM
               KODI[CR]=PROGRAM_CD
               NADI[CR]=PROGRAM_NM
               SKIP
            ENDDO
            set colo to w+/RB,gr+/r
            @ 10,43 clea to 16,71
            @ 10,43 to 16,71 double
            pilih=achoice(11,45,15,69,FILD)
            IF LASTKEY()=13
               KODE =KODI[PILIH]
               NMDIV=NADI[PILIH]
            ELSE
               KODE =SPACE(2)
               NMDIV=SPACE(16)
            ENDIF
             SET COLO TO BG+/B,W+/N
            LOCA FOR PROGRAM_CD=KODE
            RESTSCREEN(0,0,24,79,LY1)
      case option = 2
         go top
      case option = 3
         go bottom
      case option = 4
         skip
         if eof()
            go bottom
            LAYAR=SAVESCREEN(0,0,24,79)
            set colo to W+/b,w+/B
            @ 23,09 clea to 23,69
            @ 23,10 SAY 'LAST RECORD'
            WAIT ' '
            SET COLO TO
            RESTSCREEN(0,0,24,79,LAYAR)
         endif
      case option = 5
         skip -1
         if bof()
            go top
            LAYAR=SAVESCREEN(0,0,24,79)
            set colo to W+/b,w+/B
            @ 23,09 clea to 23,69
            @ 23,10 SAY 'FIRST RECORD'
            WAIT ' '
            SET COLO TO
            RESTSCREEN(0,0,24,79,LAYAR)
         endif
      case option = 6
         SET DELI OFF
         SET INTE ON
         @ 11,23 get name   pict '@!'
         read
         LAYAR=SAVESCREEN(0,0,24,79)
         choice = ' '
         do get_optn with 'SAVE (Y/N)','YN',choice
         if choice = 'Y'
            if rec_lock()
               repl PROGRAM_NM    with name
            endif
            unlock
         endif
         RESTSCREEN(0,0,24,79,LAYAR)
      case option = 7
         do while .T.
            kode     = spac(2)
            name     = spac(16)
            SET COLO TO BG+/B,W+/N
            @ 12,2 CLEAR TO 23,78
            @ 10,23 say kode
            @ 11,23 say name
            set deli off
            set inte on
            go bott
            kodea=str((val(PROGRAM_CD)+1),3)
            DO CASE
            CASE LEN(ALLTRIM(KODEA))=1
               KODE='0'+ALLTRIM(KODEA)
            CASE LEN(ALLTRIM(KODEA))=2
               KODE=ALLTRIM(KODEA)
            ENDCASE


            @ 10,23 SAY KODE PICT '@!'
            @ 11,23 get name   pict '@!'
            read
            IF LASTKEY()=27
               EXIT
            ENDIF
            LAYAR=SAVESCREEN(0,0,24,79)
            choice = 'Y'
            do get_optn with 'SAVE (Y/N)','YN',choice
            if choice = 'Y'
               if fil_lock()
                  append blank
               endif
               if rec_lock()
                  repl PROGRAM_CD    with kode
                  repl PROGRAM_NM    with name
               endif
               unlock
               NOR=RECNO()
            else
               LOOP
            endif
            anext = 'Y'
            do get_optn with 'ADD ANOTHER ONE (Y/N)','YN',ANEXT
            if ANEXT= 'Y'
               GOTO NOR
               @ 23,09 clear to 23,69
               RESTSCREEN(0,0,24,79,LAYAR)
               loop
            ELSE
               EXIT
            ENDIF
         enddo
      case option = 8
         LAYAR=SAVESCREEN(0,0,24,79)
         choice = 'N'
         do get_optn with 'Delete (Y/N)','YN',choice
         if choice = 'Y'
            if rec_lock(0)
               delete
            endif
            unlock
            del_rec = 'Y'
            go bottom
         endif
         RESTSCREEN(0,0,24,79,LAYAR)
      other
         loop
   endcase
enddo
close data
close index
set inte on
return

